#pragma once

#include <QObject>
#include <QThread>
#include <QReadWriteLock> 
#include "Drive.h"
#include "File.h"

class CopyThread : public QObject
{
	Q_OBJECT

public:
	CopyThread(QObject *parent = nullptr);
	~CopyThread();
	void HandleCopyProgress(int _iProgressValue);
	void HandleCopyDirProgress(int _iProgressValue);
	void* GetItemData(const TreeItem* _pItem);
	int GetCopyTaskType() { return m_iCopyTaskType; }
	File *GetCopyDrePtr() { return m_pDre; }

signals:
	void SignProgress(int _iCurNums);
	void SignCopyFileProgress(int _iCurValue);
	void SignFinished();
	void SignNewFile(int _iType, File *_pDre);
	void SignUpdateFile(int _iType, File *_pDre);

public slots:
	void DoCopyFile(TreeItem* _pSrc, TreeItem* _pDre);
	void DoCopyDir(int iFileIndex, const QString& _qstrRootPath, const QString& _qstrPath, TreeItem* _pSrcItem, TreeItem* _pDreItem);
	void SetCopyTaskStatus(bool _blDoCopy); //true:start copy , false:cancel copy

public:
	QReadWriteLock m_lock;
	bool m_blDoCopy = true;
	File *m_pSrc = nullptr;
	File *m_pDre = nullptr;
	int m_iCopyTaskType = FileType_File;
	CopyFileData *m_pCopyData = nullptr;
};
